.btn {
  box-shadow: none;

  &.loading {
    &::before {
      display: inline-block;
      @include icon-fa($fa-var-spinner);
      @extend .fa-spin;
      margin-right: 0.625rem;
    }
  }

  > i {
    font-size: 90%;

    + .btn-label {
      margin-left: 0.25rem;
    }
  }
}


// Alternative delete button (no background color until hover)

.btn-delete {
  color: $danger;

  &:hover, &:focus {
    color: color-contrast($danger);
    background: $danger;
  }
}


// New resource button does not show label by default

.btn-new-resource {
  > i {
    font-size: 100%;
  }

  .btn-label {
    @include visually-hidden;
  }
}


// Button icon/label visibility

@mixin button-child-visible($prefix, $selector) {
  &.#{$prefix}-visible-xs,
  &.#{$prefix}-visible-sm,
  &.#{$prefix}-visible-md,
  &.#{$prefix}-visible-lg {
    #{$selector} { display: none; }
  }

  &.#{$prefix}-visible-xs {
    @include media-breakpoint-only(xs) {
      #{$selector} { display: inline-block; }
      @content;
    }
  }

  &.#{$prefix}-visible-sm {
    @include media-breakpoint-only(sm) {
      #{$selector} { display: inline-block; }
      @content;
    }
  }

  &.#{$prefix}-visible-md {
    @include media-breakpoint-only(md) {
      #{$selector} { display: inline-block; }
      @content;
    }
  }

  &.#{$prefix}-visible-lg {
    @include media-breakpoint-up(lg) {
      #{$selector} { display: inline-block; }
      @content;
    }
  }
}

@mixin button-child-hidden($prefix, $selector) {
  &.#{$prefix}-hidden-xs {
    @include media-breakpoint-only(xs) {
      #{$selector} { display: none; }
      @content;
    }
  }

  &.#{$prefix}-hidden-sm {
    @include media-breakpoint-only(sm) {
      #{$selector} { display: none; }
      @content;
    }
  }

  &.#{$prefix}-hidden-md {
    @include media-breakpoint-only(md) {
      #{$selector} { display: none; }
      @content;
    }
  }

  &.#{$prefix}-hidden-lg {
    @include media-breakpoint-up(lg) {
      #{$selector} { display: none; }
      @content;
    }
  }
}

.btn {
  &.icon-visible-xs,
  &.icon-visible-sm,
  &.icon-visible-md,
  &.icon-visible-lg {
    > i + .btn-label {
      margin-left: 0;
    }
  }

  @include button-child-visible('icon', '> i') {
    > i + .btn-label {
      margin-left: 0.25rem;
    }
  };

  @include button-child-hidden('icon', '> i') {
    > i + .btn-label {
      margin-left: 0;
    }
  };

  @include button-child-visible('label', '> .btn-label');
  @include button-child-hidden('label', '> .btn-label');
}
